<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台管理系统 Layout</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f7fa;
            color: #333;
            height: 100vh;
            overflow: hidden;
        }

        /* 主布局容器 */
        .layout-container {
            display: flex;
            height: 100vh;
            transition: all 0.3s ease;
        }

        /* 侧边栏样式 */
        .sidebar {
            width: 220px;
            background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
            color: white;
            height: 100vh;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
            display: flex;
            flex-direction: column;
            z-index: 100;
            position: relative;
        }

        /* 折叠状态下的侧边栏 */
        .sidebar.collapsed {
            width: 64px;
        }

        /* 侧边栏头部 */
        .sidebar-header {
            padding: 20px 15px;
            display: flex;
            align-items: center;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            transition: all 0.3s ease;
        }

        .sidebar.collapsed .sidebar-header {
            justify-content: center;
            padding: 20px 0;
        }

        .logo {
            width: 32px;
            height: 32px;
            background: linear-gradient(45deg, #3498db, #9b59b6);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 12px;
            font-weight: bold;
            font-size: 16px;
        }

        .logo-text {
            font-size: 18px;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            transition: opacity 0.3s ease;
        }

        .sidebar.collapsed .logo-text {
            opacity: 0;
            width: 0;
            margin-right: 0;
        }

        /* 折叠按钮 - 位于侧边栏和头部之间 */
        .toggle-btn {
            position: absolute;
            top: 15px;
            right: -12px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: 3px solid white;
            color: white;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
            z-index: 101;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .toggle-btn:hover {
            transform: scale(1.1);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .toggle-btn i {
            font-size: 12px;
            transition: transform 0.3s ease;
        }

        .sidebar:not(.collapsed) .toggle-btn i {
            transform: rotate(180deg);
        }

        /* 菜单列表 */
        .menu-list {
            flex: 1;
            overflow-y: auto;
            padding: 15px 0;
        }

        .menu-item {
            display: flex;
            align-items: center;
            padding: 12px 20px;
            cursor: pointer;
            transition: all 0.2s ease;
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
        }

        .menu-item:hover {
            background: rgba(255, 255, 255, 0.1);
            color: white;
        }

        .menu-item.active {
            background: rgba(52, 152, 219, 0.3);
            color: white;
            border-left: 3px solid #3498db;
        }

        .menu-icon {
            width: 20px;
            text-align: center;
            margin-right: 15px;
            font-size: 16px;
            transition: all 0.3s ease;
        }

        .menu-text {
            white-space: nowrap;
            overflow: hidden;
            transition: opacity 0.3s ease;
        }

        .sidebar.collapsed .menu-text {
            opacity: 0;
            width: 0;
            margin-right: 0;
        }

        .sidebar.collapsed .menu-item {
            justify-content: center;
            padding: 15px 0;
        }

        .sidebar.collapsed .menu-icon {
            margin-right: 0;
        }

        /* 主内容区域 */
        .main-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            height: 100vh;
            transition: all 0.3s ease;
        }

        /* 头部区域 */
        .header {
            height: 60px;
            background: white;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            display: flex;
            align-items: center;
            padding: 0 24px;
            z-index: 99;
            position: relative;
        }

        .breadcrumb {
            flex: 1;
            display: flex;
            align-items: center;
            color: #666;
            font-size: 14px;
        }

        .breadcrumb-item {
            margin-right: 8px;
        }

        .breadcrumb-item:not(:last-child)::after {
            content: '/';
            margin-left: 8px;
            color: #ccc;
        }

        .header-actions {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .action-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: #f8f9fa;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #666;
            transition: all 0.3s ease;
            position: relative;
        }

        .action-btn:hover {
            background: #e9ecef;
            color: #333;
            transform: translateY(-2px);
        }

        /* 徽章样式 */
        .badge {
            position: absolute;
            top: -5px;
            right: -5px;
            background: #e74c3c;
            color: white;
            border-radius: 50%;
            width: 18px;
            height: 18px;
            font-size: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
        }

        /* 下拉菜单样式 */
        .dropdown {
            position: absolute;
            top: 100%;
            right: 0;
            width: 320px;
            background: white;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
            z-index: 1000;
            transform: translateY(10px);
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .dropdown.show {
            transform: translateY(0);
            opacity: 1;
            visibility: visible;
        }

        .dropdown-header {
            padding: 16px 20px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .dropdown-title {
            font-size: 16px;
            font-weight: 600;
            color: #2c3e50;
        }

        .dropdown-link {
            color: #3498db;
            text-decoration: none;
            font-size: 14px;
        }

        .dropdown-link:hover {
            text-decoration: underline;
        }

        .dropdown-list {
            max-height: 300px;
            overflow-y: auto;
        }

        .dropdown-item {
            padding: 15px 20px;
            border-bottom: 1px solid #f5f5f5;
            cursor: pointer;
            transition: background 0.2s ease;
        }

        .dropdown-item:hover {
            background: #f8f9fa;
        }

        .dropdown-item:last-child {
            border-bottom: none;
        }

        .item-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 8px;
        }

        .item-title {
            font-weight: 600;
            color: #2c3e50;
            font-size: 14px;
        }

        .item-time {
            color: #999;
            font-size: 12px;
        }

        .item-content {
            color: #666;
            font-size: 13px;
            line-height: 1.4;
        }

        .item-unread {
            background: #e3f2fd;
        }

        .empty-state {
            padding: 40px 20px;
            text-align: center;
            color: #999;
        }

        .empty-icon {
            font-size: 48px;
            margin-bottom: 15px;
            color: #ddd;
        }

        .empty-text {
            font-size: 14px;
        }

        /* 用户菜单特殊样式 */
        .user-dropdown {
            width: 200px;
        }

        .user-info {
            display: flex;
            align-items: center;
            padding: 15px 20px;
            border-bottom: 1px solid #eee;
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: linear-gradient(45deg, #3498db, #9b59b6);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            margin-right: 12px;
        }

        .user-name {
            font-weight: 600;
            color: #2c3e50;
        }

        .user-role {
            font-size: 12px;
            color: #999;
        }

        .user-menu {
            padding: 8px 0;
        }

        .user-menu-item {
            padding: 12px 20px;
            display: flex;
            align-items: center;
            color: #666;
            text-decoration: none;
            transition: all 0.2s ease;
        }

        .user-menu-item:hover {
            background: #f8f9fa;
            color: #333;
        }

        .user-menu-item i {
            margin-right: 10px;
            width: 16px;
            text-align: center;
        }

        .user-menu-divider {
            height: 1px;
            background: #eee;
            margin: 8px 0;
        }

        /* 内容区域 */
        .content {
            flex: 1;
            padding: 24px;
            overflow-y: auto;
            background: #f5f7fa;
        }

        .content-title {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 24px;
            color: #2c3e50;
        }

        .card {
            background: white;
            border-radius: 12px;
            padding: 24px;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
            margin-bottom: 24px;
        }

        .card-title {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 16px;
            color: #2c3e50;
        }

        /* 抽屉样式 */
        .drawer-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .drawer-overlay.open {
            opacity: 1;
            visibility: visible;
        }

        .drawer {
            position: fixed;
            top: 0;
            right: 0;
            width: 320px;
            height: 100vh;
            background: white;
            box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
            transform: translateX(100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 1001;
            display: flex;
            flex-direction: column;
        }

        .drawer-overlay.open .drawer {
            transform: translateX(0);
        }

        .drawer-header {
            padding: 20px 24px;
            border-bottom: 1px solid #eee;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .drawer-title {
            font-size: 18px;
            font-weight: 600;
            color: #2c3e50;
        }

        .close-btn {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #999;
            transition: all 0.3s ease;
        }

        .close-btn:hover {
            color: #333;
            transform: rotate(90deg);
        }

        .drawer-content {
            flex: 1;
            padding: 24px;
            overflow-y: auto;
        }

        .setting-group {
            margin-bottom: 24px;
        }

        .setting-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 16px;
            color: #2c3e50;
        }

        .setting-item {
            margin-bottom: 16px;
        }

        .setting-label {
            display: block;
            margin-bottom: 8px;
            font-size: 14px;
            color: #666;
        }

        .theme-options {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
        }

        .theme-option {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            cursor: pointer;
            border: 2px solid transparent;
            transition: all 0.3s ease;
        }

        .theme-option:hover {
            transform: scale(1.1);
        }

        .theme-option.active {
            border-color: #3498db;
            transform: scale(1.1);
        }

        .layout-options {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
        }

        .layout-option {
            padding: 12px;
            border: 2px solid #eee;
            border-radius: 8px;
            cursor: pointer;
            text-align: center;
            transition: all 0.3s ease;
        }

        .layout-option:hover {
            border-color: #3498db;
            background: #f8f9fa;
        }

        .layout-option.active {
            border-color: #3498db;
            background: #e3f2fd;
        }

        .layout-preview {
            width: 100%;
            height: 60px;
            background: #f8f9fa;
            border-radius: 4px;
            margin-bottom: 8px;
            display: flex;
        }

        .preview-sidebar {
            width: 20px;
            background: #34495e;
            border-radius: 2px 0 0 2px;
        }

        .preview-content {
            flex: 1;
            background: white;
            border-radius: 0 2px 2px 0;
        }

        .preview-header {
            height: 15px;
            background: #3498db;
            border-radius: 2px 2px 0 0;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .sidebar {
                position: fixed;
                transform: translateX(-100%);
            }
            
            .sidebar.show {
                transform: translateX(0);
            }
            
            .sidebar.collapsed {
                width: 220px;
            }
            
            .sidebar.collapsed .logo-text,
            .sidebar.collapsed .menu-text {
                opacity: 1;
                width: auto;
                margin-right: 12px;
            }
            
            .sidebar.collapsed .menu-item {
                justify-content: flex-start;
                padding: 12px 20px;
            }
            
            .sidebar.collapsed .menu-icon {
                margin-right: 15px;
            }
            
            .drawer {
                width: 100%;
            }
            
            .dropdown {
                width: 280px;
            }
        }

        /* 滚动条样式 */
        ::-webkit-scrollbar {
            width: 6px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
        }

        ::-webkit-scrollbar-thumb {
            background: rgba(0, 0, 0, 0.2);
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 0, 0, 0.3);
        }
    </style>
</head>
<body>
    <!-- 主布局容器 -->
    <div class="layout-container">
        <!-- 侧边栏 -->
        <div class="sidebar" id="sidebar">
            <div class="sidebar-header">
                <div class="logo">A</div>
                <div class="logo-text">Admin Panel</div>
            </div>
            
            <!-- 折叠按钮 -->
            <button class="toggle-btn" id="toggleSidebar">
                <i class="fas fa-arrow-right"></i>
                <!-- <i class="fas fa-chevron-left"></i> -->
                <!-- <i class="fas fas fa-arrow-right"></i> -->
                <!-- <i class="fas fas fa-bars"></i> -->
            </button>
            
            <div class="menu-list">
                <a href="#" class="menu-item active">
                    <i class="fas fa-home menu-icon"></i>
                    <span class="menu-text">仪表板</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-users menu-icon"></i>
                    <span class="menu-text">用户管理</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-chart-bar menu-icon"></i>
                    <span class="menu-text">数据分析</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-cog menu-icon"></i>
                    <span class="menu-text">系统设置</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-file-alt menu-icon"></i>
                    <span class="menu-text">文档管理</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-envelope menu-icon"></i>
                    <span class="menu-text">消息中心</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-shopping-cart menu-icon"></i>
                    <span class="menu-text">订单管理</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-question-circle menu-icon"></i>
                    <span class="menu-text">帮助中心</span>
                </a>
            </div>
        </div>

        <!-- 主内容区域 -->
        <div class="main-container">
            <!-- 头部区域 -->
            <div class="header">
                <div class="breadcrumb">
                    <span class="breadcrumb-item">首页</span>
                    <span class="breadcrumb-item">仪表板</span>
                    <span class="breadcrumb-item">概览</span>
                </div>
                
                <div class="header-actions">
                    <!-- 通知按钮 -->
                    <button class="action-btn" id="notificationBtn" title="通知">
                        <i class="fas fa-bell"></i>
                        <span class="badge" id="notificationBadge">3</span>
                    </button>
                    
                    <!-- 消息按钮 -->
                    <button class="action-btn" id="messageBtn" title="消息">
                        <i class="fas fa-envelope"></i>
                        <span class="badge" id="messageBadge">5</span>
                    </button>
                    
                    <!-- 设置按钮 -->
                    <button class="action-btn" id="openDrawer" title="设置">
                        <i class="fas fa-cog"></i>
                    </button>
                    
                    <!-- 用户按钮 -->
                    <button class="action-btn" id="userBtn" title="用户">
                        <i class="fas fa-user"></i>
                    </button>
                </div>
                
                <!-- 通知下拉菜单 -->
                <div class="dropdown" id="notificationDropdown">
                    <div class="dropdown-header">
                        <div class="dropdown-title">通知 (3)</div>
                        <a href="#" class="dropdown-link">查看全部</a>
                    </div>
                    <div class="dropdown-list">
                        <div class="dropdown-item item-unread">
                            <div class="item-header">
                                <div class="item-title">系统更新</div>
                                <div class="item-time">2分钟前</div>
                            </div>
                            <div class="item-content">系统将在今晚12点进行维护升级，请提前保存工作。</div>
                        </div>
                        <div class="dropdown-item item-unread">
                            <div class="item-header">
                                <div class="item-title">安全提醒</div>
                                <div class="item-time">15分钟前</div>
                            </div>
                            <div class="item-content">检测到异常登录尝试，请检查您的账户安全设置。</div>
                        </div>
                        <div class="dropdown-item">
                            <div class="item-header">
                                <div class="item-title">新功能上线</div>
                                <div class="item-time">1小时前</div>
                            </div>
                            <div class="item-content">数据分析模块新增图表类型，点击查看详细说明。</div>
                        </div>
                        <div class="dropdown-item">
                            <div class="item-header">
                                <div class="item-title">系统公告</div>
                                <div class="item-time">3小时前</div>
                            </div>
                            <div class="item-content">本月系统维护计划已发布，请查看相关安排。</div>
                        </div>
                    </div>
                </div>
                
                <!-- 消息下拉菜单 -->
                <div class="dropdown" id="messageDropdown">
                    <div class="dropdown-header">
                        <div class="dropdown-title">消息 (5)</div>
                        <a href="#" class="dropdown-link">查看全部</a>
                    </div>
                    <div class="dropdown-list">
                        <div class="dropdown-item item-unread">
                            <div class="item-header">
                                <div class="item-title">张三</div>
                                <div class="item-time">5分钟前</div>
                            </div>
                            <div class="item-content">请问这个项目的进度如何了？</div>
                        </div>
                        <div class="dropdown-item item-unread">
                            <div class="item-header">
                                <div class="item-title">李四</div>
                                <div class="item-time">25分钟前</div>
                            </div>
                            <div class="item-content">附件中的文档我已经审阅完毕。</div>
                        </div>
                        <div class="dropdown-item">
                            <div class="item-header">
                                <div class="item-title">王五</div>
                                <div class="item-time">2小时前</div>
                            </div>
                            <div class="item-content">明天的会议时间调整到下午3点。</div>
                        </div>
                        <div class="dropdown-item">
                            <div class="item-header">
                                <div class="item-title">赵六</div>
                                <div class="item-time">昨天</div>
                            </div>
                            <div class="item-content">新功能的需求文档已经完成，请查收。</div>
                        </div>
                        <div class="dropdown-item">
                            <div class="item-header">
                                <div class="item-title">系统消息</div>
                                <div class="item-time">昨天</div>
                            </div>
                            <div class="item-content">您的账户信息已成功更新。</div>
                        </div>
                    </div>
                </div>
                
                <!-- 用户下拉菜单 -->
                <div class="dropdown user-dropdown" id="userDropdown">
                    <div class="user-info">
                        <div class="user-avatar">A</div>
                        <div>
                            <div class="user-name">管理员</div>
                            <div class="user-role">超级管理员</div>
                        </div>
                    </div>
                    <div class="user-menu">
                        <a href="#" class="user-menu-item">
                            <i class="fas fa-user"></i>
                            个人资料
                        </a>
                        <a href="#" class="user-menu-item">
                            <i class="fas fa-cog"></i>
                            账户设置
                        </a>
                        <div class="user-menu-divider"></div>
                        <a href="#" class="user-menu-item">
                            <i class="fas fa-sign-out-alt"></i>
                            退出登录
                        </a>
                    </div>
                </div>
            </div>

            <!-- 内容区域 -->
            <div class="content">
                <h1 class="content-title">仪表板概览</h1>
                
                <div class="card">
                    <h2 class="card-title">系统状态</h2>
                    <p>欢迎使用后台管理系统！这是一个功能完整的管理界面布局示例。</p>
                </div>
                
                <div class="card">
                    <h2 class="card-title">数据统计</h2>
                    <p>这里可以显示各种业务数据和统计信息。</p>
                </div>
                
                <div class="card">
                    <h2 class="card-title">最近活动</h2>
                    <p>显示系统最近的操作记录和活动日志。</p>
                </div>
            </div>
        </div>
    </div>

    <!-- 抽屉遮罩层 -->
    <div class="drawer-overlay" id="drawerOverlay">
        <div class="drawer">
            <div class="drawer-header">
                <div class="drawer-title">系统设置</div>
                <button class="close-btn" id="closeDrawer">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="drawer-content">
                <div class="setting-group">
                    <h3 class="setting-title">主题设置</h3>
                    <div class="setting-item">
                        <label class="setting-label">选择主题颜色</label>
                        <div class="theme-options">
                            <div class="theme-option active" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);" data-theme="default"></div>
                            <div class="theme-option" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);" data-theme="pink"></div>
                            <div class="theme-option" style="background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);" data-theme="green"></div>
                            <div class="theme-option" style="background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);" data-theme="yellow"></div>
                        </div>
                    </div>
                </div>
                
                <div class="setting-group">
                    <h3 class="setting-title">布局设置</h3>
                    <div class="setting-item">
                        <label class="setting-label">选择布局模式</label>
                        <div class="layout-options">
                            <div class="layout-option active" data-layout="default">
                                <div class="layout-preview">
                                    <div class="preview-sidebar"></div>
                                    <div class="preview-content">
                                        <div class="preview-header"></div>
                                    </div>
                                </div>
                                <div>默认布局</div>
                            </div>
                            <div class="layout-option" data-layout="compact">
                                <div class="layout-preview">
                                    <div class="preview-sidebar" style="width: 15px;"></div>
                                    <div class="preview-content">
                                        <div class="preview-header" style="height: 12px;"></div>
                                    </div>
                                </div>
                                <div>紧凑布局</div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="setting-group">
                    <h3 class="setting-title">其他设置</h3>
                    <div class="setting-item">
                        <label class="setting-label">
                            <input type="checkbox" checked> 启用动画效果
                        </label>
                    </div>
                    <div class="setting-item">
                        <label class="setting-label">
                            <input type="checkbox"> 显示面包屑导航
                        </label>
                    </div>
                    <div class="setting-item">
                        <label class="setting-label">
                            <input type="checkbox" checked> 固定侧边栏
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 获取DOM元素
        const sidebar = document.getElementById('sidebar');
        const toggleSidebarBtn = document.getElementById('toggleSidebar');
        const openDrawerBtn = document.getElementById('openDrawer');
        const closeDrawerBtn = document.getElementById('closeDrawer');
        const drawerOverlay = document.getElementById('drawerOverlay');
        
        // 头部操作按钮
        const notificationBtn = document.getElementById('notificationBtn');
        const messageBtn = document.getElementById('messageBtn');
        const userBtn = document.getElementById('userBtn');
        
        // 下拉菜单
        const notificationDropdown = document.getElementById('notificationDropdown');
        const messageDropdown = document.getElementById('messageDropdown');
        const userDropdown = document.getElementById('userDropdown');
        
        // 徽章
        const notificationBadge = document.getElementById('notificationBadge');
        const messageBadge = document.getElementById('messageBadge');
        
        // 主题和布局选项
        const themeOptions = document.querySelectorAll('.theme-option');
        const layoutOptions = document.querySelectorAll('.layout-option');

        // 切换侧边栏折叠状态
        toggleSidebarBtn.addEventListener('click', () => {
            sidebar.classList.toggle('collapsed');
            
            // 更新按钮图标旋转方向
            const icon = toggleSidebarBtn.querySelector('i');
            if (sidebar.classList.contains('collapsed')) {
                icon.style.transform = 'rotate(0deg)';
            } else {
                icon.style.transform = 'rotate(180deg)';
            }
        });

        // 打开抽屉
        openDrawerBtn.addEventListener('click', () => {
            closeAllDropdowns();
            drawerOverlay.classList.add('open');
            document.body.style.overflow = 'hidden'; // 防止背景滚动
        });

        // 关闭抽屉
        closeDrawerBtn.addEventListener('click', () => {
            closeDrawer();
        });

        // 点击遮罩层关闭抽屉
        drawerOverlay.addEventListener('click', (e) => {
            if (e.target === drawerOverlay) {
                closeDrawer();
            }
        });

        // ESC键关闭抽屉
        document.addEventListener('keydown', (e) => {
            if (e.key === 'Escape' && drawerOverlay.classList.contains('open')) {
                closeDrawer();
            }
        });

        // 关闭抽屉的函数
        function closeDrawer() {
            drawerOverlay.classList.remove('open');
            document.body.style.overflow = ''; // 恢复背景滚动
        }

        // 下拉菜单控制
        let currentOpenDropdown = null;

        // 通知按钮点击事件
        notificationBtn.addEventListener('click', (e) => {
            e.stopPropagation();
            closeDrawer();
            toggleDropdown(notificationDropdown);
            // 点击后清除徽章（模拟已读）
            if (notificationBadge) {
                notificationBadge.style.display = 'none';
            }
        });

        // 消息按钮点击事件
        messageBtn.addEventListener('click', (e) => {
            e.stopPropagation();
            closeDrawer();
            toggleDropdown(messageDropdown);
            // 点击后清除徽章（模拟已读）
            if (messageBadge) {
                messageBadge.style.display = 'none';
            }
        });

        // 用户按钮点击事件
        userBtn.addEventListener('click', (e) => {
            e.stopPropagation();
            closeDrawer();
            toggleDropdown(userDropdown);
        });

        // 切换下拉菜单显示/隐藏
        function toggleDropdown(dropdown) {
            if (currentOpenDropdown && currentOpenDropdown !== dropdown) {
                currentOpenDropdown.classList.remove('show');
            }
            
            dropdown.classList.toggle('show');
            currentOpenDropdown = dropdown.classList.contains('show') ? dropdown : null;
        }

        // 关闭所有下拉菜单
        function closeAllDropdowns() {
            const dropdowns = document.querySelectorAll('.dropdown');
            dropdowns.forEach(dropdown => {
                dropdown.classList.remove('show');
            });
            currentOpenDropdown = null;
        }

        // 点击页面其他地方关闭下拉菜单和抽屉
        document.addEventListener('click', (e) => {
            if (!e.target.closest('.action-btn') && 
                !e.target.closest('.dropdown') && 
                !e.target.closest('.drawer')) {
                closeAllDropdowns();
            }
        });

        // 下拉菜单项点击事件（标记为已读）
        const dropdownItems = document.querySelectorAll('.dropdown-item');
        dropdownItems.forEach(item => {
            item.addEventListener('click', function(e) {
                e.stopPropagation();
                this.classList.remove('item-unread');
                
                // 更新徽章数量
                const parentDropdown = this.closest('.dropdown');
                if (parentDropdown === notificationDropdown) {
                    const unreadCount = notificationDropdown.querySelectorAll('.item-unread').length;
                    if (unreadCount > 0) {
                        notificationBadge.textContent = unreadCount;
                    } else {
                        notificationBadge.style.display = 'none';
                    }
                } else if (parentDropdown === messageDropdown) {
                    const unreadCount = messageDropdown.querySelectorAll('.item-unread').length;
                    if (unreadCount > 0) {
                        messageBadge.textContent = unreadCount;
                    } else {
                        messageBadge.style.display = 'none';
                    }
                }
            });
        });

        // 主题切换功能
        themeOptions.forEach(option => {
            option.addEventListener('click', () => {
                // 移除所有激活状态
                themeOptions.forEach(opt => opt.classList.remove('active'));
                // 激活当前选项
                option.classList.add('active');
                
                // 这里可以添加实际的主题切换逻辑
                console.log('切换到主题:', option.getAttribute('data-theme'));
            });
        });

        // 布局切换功能
        layoutOptions.forEach(option => {
            option.addEventListener('click', () => {
                // 移除所有激活状态
                layoutOptions.forEach(opt => opt.classList.remove('active'));
                // 激活当前选项
                option.classList.add('active');
                
                // 这里可以添加实际的布局切换逻辑
                console.log('切换到布局:', option.getAttribute('data-layout'));
            });
        });

        // 菜单项点击事件
        const menuItems = document.querySelectorAll('.menu-item');
        menuItems.forEach(item => {
            item.addEventListener('click', (e) => {
                e.preventDefault();
                // 移除所有激活状态
                menuItems.forEach(i => i.classList.remove('active'));
                // 激活当前项
                item.classList.add('active');
            });
        });

        // 响应式处理
        function handleResponsive() {
            if (window.innerWidth <= 768) {
                // 移动端处理
                sidebar.classList.add('collapsed');
            } else {
                // 桌面端处理
                sidebar.classList.remove('collapsed');
            }
        }

        // 页面加载时处理响应式
        window.addEventListener('load', handleResponsive);
        // 窗口大小改变时处理响应式
        window.addEventListener('resize', handleResponsive);

        // 初始化按钮图标方向
        if (!sidebar.classList.contains('collapsed')) {
            toggleSidebarBtn.querySelector('i').style.transform = 'rotate(180deg)';
        }
    </script>
</body>
</html>
